﻿@namespace Xms.Abp.Components

@typeparam TService
@typeparam TModel
@typeparam TKey
@inherits AntDomComponentBase

<Form TModel="TModel" Model="Model" Size="small" OnFinish="OnFinishAsync" Loading="Submiting" OnFinishFailed="OnFinishFailedAsync" id="@Id" Class="details-form">
    @if (DialogAction != DialogAction.Details)
    {
        <div class="details-form-content">
            <div style="margin:24px;">
                @ChildContent(context)
                @if (Model is IReviewAuditObject<string> reviewModel)
                {
                    <Divider Text="审核信息" Orientation="left" />
                    <Row Gutter="16">
                        <AntDesign.Col Span="12">
                            <FormItem LabelColSpan="8" WrapperColSpan="16">
                                <Input @bind-Value="reviewModel.ReviewerNo" ReadOnly="DialogAction == DialogAction.Details || DialogAction == DialogAction.Review" />
                            </FormItem>
                        </AntDesign.Col>
                    </Row>
                    <Row Gutter="16">
                        <AntDesign.Col Span="24">
                            <FormItem LabelColSpan="4" WrapperColSpan="20">
                                <TextArea @bind-Value="reviewModel.ReviewRemark" />
                            </FormItem>
                        </AntDesign.Col>
                    </Row>
                }
            </div>
        </div>
        <style>
            .ant-modal-body+.ant-modal-footer{display:none;}
            .ant-modal-body .details-buttons.ant-modal-footer{margin:0 -24px -24px -24px;}
            .ant-drawer-body{padding:0;}
            .ant-drawer-body .ant-spin-nested-loading,
            .ant-drawer-body .ant-spin-nested-loading>div, .ant-drawer-body .ant-spin-container,
            .details-form{height:100%;}
            .details-form-content{height:calc(100% - 53px);overflow-y:auto;}
        </style>
        <div class="details-buttons ant-modal-footer">
            <div>
                @if (DialogAction != DialogAction.Review)
                {
                <Button Type="@ButtonType.Primary" HtmlType="submit" Size="default" Loading="Submiting">保存</Button>
                }
                else
                {
                <Popconfirm Title="@("确定要审核通过吗？")" OnConfirm="ApprovedAsync" OkText="确定" CancelText="取消">
                    <Button Type="@ButtonType.Primary" Size="default" Loading="Submiting">审核通过</Button>
                </Popconfirm>
                <Popconfirm Title="@("确定要审核驳回吗？")" OnConfirm="RejectAsync" OkText="确定" CancelText="取消">
                    <Button Type="@ButtonType.Default" Size="default" Loading="Submiting">审核驳回</Button>
                </Popconfirm>
                }
                <Popconfirm Title="@("确定要取消"+(DialogAction == DialogAction.Create ? "创建" : "修改")+"吗？")" OnConfirm="CloseFeedbackAsync" OkText="确定" CancelText="取消">
                    <Button Type="@ButtonType.Default" Size="default">取消</Button>
                </Popconfirm>
            </div>
        </div>
    }
    else
    {
        @if (!DefaultTabTitle.IsNullOrWhiteSpace() && TabPanes != null)
        {
            <Tabs DefaultActiveKey="1" Animated>
                <TabPane Tab="@DefaultTabTitle" Key="1">
                    @ChildContent(context)
                    @if (Model is IReviewAuditObject<string> reviewModel)
                    {
                        <Divider Text="审核信息" Orientation="left" />
                        <Row Gutter="16">
                            <AntDesign.Col Span="12">
                                <FormItem LabelColSpan="8" WrapperColSpan="16">
                                @if (reviewModel.ReviewStatus == ReviewStatus.Draft || reviewModel.ReviewStatus == ReviewStatus.Reviewing)
                                {
                                    <Input @bind-Value="reviewModel.ReviewerNo" ReadOnly />
                                }
                                else
                                {
                                    <Input @bind-Value="reviewModel.Reviewer" ReadOnly />
                                }
                                </FormItem>
                            </AntDesign.Col>
                            <AntDesign.Col Span="12">
                                <FormItem LabelColSpan="8" WrapperColSpan="16">
                                    <EnumSelect @bind-Value="reviewModel.ReviewStatus" Disabled />
                                </FormItem>
                            </AntDesign.Col>
                        </Row>
                        @if (reviewModel.ReviewStatus == ReviewStatus.Approved || reviewModel.ReviewStatus == ReviewStatus.Reject)
                        {
                        <Row Gutter="16">
                            <AntDesign.Col Span="12">
                                <FormItem LabelColSpan="8" WrapperColSpan="16">
                                    <DatePicker TValue="DateTime?" @bind-Value="reviewModel.ReviewTime" Disabled="true" />
                                </FormItem>
                            </AntDesign.Col>
                        </Row>
                        }
                        <Row Gutter="16">
                            <AntDesign.Col Span="24">
                                <FormItem LabelColSpan="4" WrapperColSpan="20">
                                    <TextArea @bind-Value="reviewModel.ReviewRemark" ReadOnly />
                                </FormItem>
                            </AntDesign.Col>
                        </Row>
                    }
                </TabPane>
                @TabPanes(context)
            </Tabs>
        }
        else
        {
            @ChildContent(context)
            @if (Model is IReviewAuditObject<string> reviewModel)
            {
                <Divider Text="审核信息" Orientation="left" />
                <Row Gutter="16">
                    <AntDesign.Col Span="12">
                        <FormItem LabelColSpan="8" WrapperColSpan="16">
                        @if (reviewModel.ReviewStatus == ReviewStatus.Draft || reviewModel.ReviewStatus == ReviewStatus.Reviewing)
                        {
                            <Input @bind-Value="reviewModel.ReviewerNo" ReadOnly />
                        }
                        else
                        {
                            <Input @bind-Value="reviewModel.Reviewer" ReadOnly />
                        }
                        </FormItem>
                    </AntDesign.Col>
                    <AntDesign.Col Span="12">
                        <FormItem LabelColSpan="8" WrapperColSpan="16">
                            <EnumSelect @bind-Value="reviewModel.ReviewStatus" Disabled />
                        </FormItem>
                    </AntDesign.Col>
                </Row>
                @if (reviewModel.ReviewStatus == ReviewStatus.Approved || reviewModel.ReviewStatus == ReviewStatus.Reject)
                {
                <Row Gutter="16">
                    <AntDesign.Col Span="12">
                        <FormItem LabelColSpan="8" WrapperColSpan="16">
                            <DatePicker TValue="DateTime?" @bind-Value="reviewModel.ReviewTime" Disabled="true" />
                        </FormItem>
                    </AntDesign.Col>
                </Row>
                }
                <Row Gutter="16">
                    <AntDesign.Col Span="24">
                        <FormItem LabelColSpan="4" WrapperColSpan="20">
                            <TextArea @bind-Value="reviewModel.ReviewRemark" ReadOnly />
                        </FormItem>
                    </AntDesign.Col>
                </Row>
            }
        }
    }
</Form>
